package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.entity.NursingProject;
import com.zzyl.vo.NursingProjectVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
public interface NursingProjectMapper {

    void insertNursingProject(NursingProject nursingProject);

    void updateNursingProject(NursingProject nursingProject);

    void deleteNursingProjectById(Long id);

    NursingProject getNursingProjectById(Long id);

    List<NursingProject> getAllNursingProjects();

    /**
     * 分页查询
     *
     * @param name
     * @param status
     * @return
     */
    Page<NursingProjectVo> pageQuery(String name, Integer status);

    @Select("select count(*) from nursing_project where name = #{name}")
    Integer selectNursingProByName(String name);

    Integer selectNursingProByNameAndId(@Param(value = "name") String name, @Param(value = "id") Long id);

    /**
     * 统计服务项目的关联计划
     *
     * @param id
     * @return
     */
    Integer selectCountNursingPlan(Long id);


    /**
     * 修改护理项目状态
     * @param id
     * @param status
     */
    @Update("update nursing_project np set status = #{status} where id = #{id} ")
    void updateStatus( @Param(value = "id") Long id, @Param(value = "status") Integer status);
}